
const YKTabbar = [
	{
		pagePath: "/pages/index/index",
		iconPath: "/static/tabbar/icon_shangpin_grey.png",
		selectedIconPath: "/static/tabbar/icon_shangpin_red.png",
		text: "商品",
		sort: 3
	},
	{
		pagePath: "/pages/mine/index",
		iconPath: "/static/tabbar/icon_wo_grey.png",
		selectedIconPath: "/static/tabbar/icon_wo_red.png",
		text: "我",
		sort: 5
	},
]
const Purchase = [
	{
		pagePath: "/pages/purchase/index",
		iconPath: "/static/tabbar/icon_mendian_grey.png",
		selectedIconPath: "/static/tabbar/icon_mendian_red.png",
		text: "采购",
		sort: 6
	}
] 
const Payment = {
	pagePath: "/pages/purchase/index",
	iconPath: "/static/tabbar/icon_mendian_grey.png",
	selectedIconPath: "/static/tabbar/icon_mendian_red.png",
	text: "采购",
	sort: 6
}
const Sale = {
	pagePath: "/pages/sale/index",
	iconPath: "/static/tabbar/icon_xiaoshou_grey.png",
	selectedIconPath: "/static/tabbar/icon_xiaoshou_red.png",
	text: "销售",
	sort: 1
}
const Delivery = {
	pagePath: "/pages/songhuo/index",
	iconPath: "/static/tabbar/icon_songhuo_grey.png",
	selectedIconPath: "/static/tabbar/icon_songhuo_red.png",
	text: "送货",
	sort: 2
}
const Owners = {
	pagePath: "/pages/owners/index",
	iconPath: "/static/tabbar/icon_pinpaishang.png",
	selectedIconPath: "/static/tabbar/icon_pinpaishang_red.png",
	text: "品牌商",
	sort: 0
}
function removeDuplicate(arr) {
    return arr.filter((item, index) => {
       return arr.indexOf(item) === index
  })
}
const ChangeArr = (data) => {
  const newdata = data.map(item => (JSON.stringify(item)))
  const useData = [...new Set(newdata)].map(item=>JSON.parse(item));
  return useData;
}
import {useUserStore} from '@/store/user.js';
function getTabbr() {
	let arr = Object.assign([], YKTabbar);
	if (!uni.getStorageSync('user')) {
		arr = Object.assign([], YKTabbar);
	} else {
		const user = uni.getStorageSync('user');
		if(user.isPurchase){
			arr = arr.concat(Purchase);
		}
		if(user.isSale){
			arr.push(Sale)
		}
		if(user.isOwner){
			arr.push(Owners)
		}
	}
	const result = ChangeArr(arr);
	result.sort(function(a, b) {
		return a.sort - b.sort
	})
	const userStore = useUserStore();
	userStore.setTabbar(result)
	return result
}

export default getTabbr
